﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Collections.ObjectModel;
using TecHappy.WindowsPhone.Sample2.Data;
using System.Windows.Media.Imaging;

namespace TecHappy.WindowsPhone.Sample2
{
    public partial class MainPage : PhoneApplicationPage
    {
        private Random r = new Random();
        private ObservableCollection<ColorModel> colors = new ObservableCollection<ColorModel>();

        public ObservableCollection<ColorModel> Colors { get { return this.colors; } }
		
        public MainPage()
        {
            InitializeComponent();
            this.DataContext = colors;
        }

        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            ColorModel color = new ColorModel(Color.FromArgb(255, (byte)r.Next(256), (byte)r.Next(256), (byte)r.Next(256)));
            this.Colors.Insert(r.Next(this.Colors.Count ), color);
        }

        private void btnRemove_Click(object sender, RoutedEventArgs e)
        {
            if (this.Colors.Count > 0)
            {
                this.Colors.RemoveAt(r.Next(this.Colors.Count));
            }
        }

        private void grid_Loaded(object sender, RoutedEventArgs e)
        {
           
        }
    }
}